package com.jt.www.enums.extend;

import org.apache.commons.lang.StringUtils;

/**
 * excel导出模板位置
 */
public enum ExcelDownFileEnum {
    EDU_DEFAULT("00", "", "excel/templates/managerlist.xls", "教育通用模板"),
    EDU_19PR596839("00", "19PR596839", "excel/templates/managerlist_19PR596839.xls", "山西"),
    WXB_DEFAULT("02", "", "excel/templates/wxbmanagerlist.xls", "我学保通用模板"),
    EDU_ENDORSE_DEFAULT("03", "", "excel/templates/endorse.xls", "批单通用模板"),
    EDU_SD("00", "19PR372456,19PR324941,19PR868691,19PR285352,19PR352719,19PR276530,19PR478694,19PR678749,19PR883658,19PR801279,19PR394185", "excel/templates/managerlist_sd.xls", "山东"),
    EDU_ACCOUNT_DEFAULT("04", "", "excel/templates/endorse_account.xls", "批单到账确认通用模板");


    /**
     * 00 教保投保单
     * 02 我学保投保单
     * 03 教保批单
     */
    private String channel;
    private String productCode;
    private String filePath;
    private String desc;

    ExcelDownFileEnum(String channel, String productCode, String filePath, String desc) {
        this.channel = channel;
        this.productCode = productCode;
        this.filePath = filePath;
        this.desc = desc;
    }

    public static ExcelDownFileEnum getEnum(String channel, String modelCode) {
        if (StringUtils.isBlank(modelCode)) {
            modelCode = "";
        }
        for (ExcelDownFileEnum excelDownFileEnum : ExcelDownFileEnum.values()) {
            if (excelDownFileEnum.channel.equals(channel) && excelDownFileEnum.productCode.equals(modelCode)) {
                return excelDownFileEnum;
            }
        }
        return EDU_DEFAULT;
    }

    public static String getFilePath(String channel, String productCode) {
        if (StringUtils.isBlank(productCode)) {
            //通过channel决定 返回教育,我学保，批单默认文件
            return EDU_DEFAULT.channel.equals(channel) ? EDU_DEFAULT.filePath :
                    WXB_DEFAULT.channel.equals(channel) ? WXB_DEFAULT.filePath : EDU_ENDORSE_DEFAULT.filePath;
        }
        for (ExcelDownFileEnum excelDownFileEnum : ExcelDownFileEnum.values()) {
            if (excelDownFileEnum.channel.equals(channel) && excelDownFileEnum.productCode.contains(productCode)) {
                return excelDownFileEnum.filePath;
            }
        }
        return EDU_DEFAULT.channel.equals(channel) ? EDU_DEFAULT.filePath : WXB_DEFAULT.filePath;
    }

    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    public String getProductCode() {
        return productCode;
    }

    public void setProductCode(String productCode) {
        this.productCode = productCode;
    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
